package com.system.announcement.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.system.announcement.dao.AnnouncementRepository;
import com.system.announcement.entity.Announcement;
@Service
@Transactional
public class AnnouncementService implements IAnnouncementService {
	@Autowired
	private AnnouncementRepository announcementRepository;
	
	public Page<Announcement> findAll(Pageable pageable) {
		// TODO Auto-generated method stub
		return announcementRepository.findAll(pageable);
	}

	public void saveOrUpdate(Announcement announcement) {
	
		 announcementRepository.save(announcement);
	}
	
	public void delete(Announcement announcement) {
	
		 announcementRepository.delete(announcement);
	}

	public void delete(List<Long> ids) {
		List<Announcement> a=(List<Announcement>) announcementRepository.findAll(ids);
		
		 announcementRepository.delete(a);
	}
	
	public Announcement findOne(Long id) {
		
		return announcementRepository.findOne(id);
	}
	public Announcement findLast() {
		return announcementRepository.findLast();
	}
}
